package com.ykdl.member.views;

import java.util.Calendar;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ykdl.member.kid.R;
import com.ykdl.member.constant.China;
import com.ykdl.member.kid.util.DateUtil;
/**
 * 
 * 自定义的滚轮的视图控件
 *
 * @since 1.0
 */
public class MyWheelView extends LinearLayout implements
		OnWheelChangedListener, View.OnClickListener {
	/**
	 * CHINA WheelView 类型, 显示地址
	 */
	public static final int CHINA = 0;
	/**
	 * KeepItem Wheelview 类型,显示项
	 */
	public static final int ITEM = 1024;

	public static final int ACCOUNT = 121;
	
	
	
	/**
	 * CALENDAR WheelView 类型, 显示日期
	 */
	public static final int CHINA_FOOT = 3;

	public static final int CALENDAR = 1;
	public static final int CALENDAR_ALL = 21;
    private boolean calendar_after_now=false;//可以超过现在的时间
	/**
	 * CALENDAR WheelView 类型, 其它类型
	 */
	public static final int OTHER = 100;

	public static final int DATATYPE_INT = 1;

	public static final int DATATYPE_STRING = 2;

	private Boolean isSlide = true;
	private Context context;
	private LayoutInflater mInflater;
	private LinearLayout mMainView;
	private LinearLayout mWheelViewGroup;
	private int mType; // 当前wheelview 使用类型
	// private int recordNum1;
	private Button mOk, mCancel, mLast;
	private OnWheelViewDataChanger listener;
	private Calendar calendar;
	private LayoutParams mParams;
	public static Animation mPush_in, mPush_out;
	private ViewGroup view;
	private EditText editText;
	private Drawable click, noclick;
	private TextView mTitle;

	private boolean isInVisible;
	private boolean isGone = true;
	private boolean isEndYesterDay=false;
	
	/**
	 * 设置日期显示到当前日期的前一天
	 * @param theEnd
	 */
	public void setEndYesterday(boolean theEnd){
		this.isEndYesterDay=theEnd;
	}

	// wheelview 弹出 和 收回时 view的drawable changer
	public void setChangerView(ViewGroup view, Drawable click, Drawable noclick) {
		this.view = view;
		this.click = click;
		this.noclick = noclick;
	}
	
	public void setTimeAfterNow(boolean endable){
		calendar_after_now=endable;
	}

	// 设置wheelview 弹出后 editText 不能点击
	public void setChangerEditText(EditText editText) {
		this.editText = editText;
	}

	public MyWheelView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		this.context = context;
		init();
	}

	public MyWheelView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		this.context = context;
		init();
	}

	public void setTitle(String title) {
		mTitle.setText(title);
	}

	public void setSlide(boolean slide) {
		isSlide = slide;
	}

	public void setInVisible(boolean inVisible) {
		isInVisible = inVisible;
	}

	public void setGone(boolean gone) {
		isGone = gone;
	}

	private void init() {
		if (mPush_in == null) {
			mPush_in = AnimationUtils.loadAnimation(context, R.anim.push_in);
		}
		if (mPush_out == null) {
			mPush_out = AnimationUtils.loadAnimation(context, R.anim.push_out);
		}

		mInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mMainView = (LinearLayout) mInflater.inflate(R.layout.my_wheelview,
				null);
		mMainView.setOnClickListener(this);
		mOk = (Button) mMainView.findViewById(R.id.my_wheelview_ok);
		mCancel = (Button) mMainView.findViewById(R.id.my_wheelview_cancel);
		mLast = (Button) mMainView.findViewById(R.id.my_wheelview_last);
		mTitle = (TextView) mMainView.findViewById(R.id.my_wheelview_title);

		mOk.setOnClickListener(this);
		mCancel.setOnClickListener(this);

		mParams = new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT, 1);

		mWheelViewGroup = (LinearLayout) mMainView
				.findViewById(R.id.my_wheelview_group);
		this.addView(mMainView);
		this.setMyGone();
	}

	public Button getWheelOkButton() {
		return mOk;
	}

	public void cancleGo() {
		mCancel.setVisibility(View.GONE);
	}

	public void cancleVi() {
		mCancel.setVisibility(View.VISIBLE);
	}
	
	
	
	public Button getWheelCancelButton() {
		mCancel.setVisibility(View.VISIBLE);
		return mCancel;
	}
	

	public Button getWheelLastButton() {
		mLast.setVisibility(View.VISIBLE);
		return mLast;
	}

	public void setNext() {
		mOk.setText("");
		// mOk.setText("下一步");
	}

	public void setDone() {
		mOk.setText("");
		// mOk.setText("确定");
	}

	public void setLastVi() {
		mLast.setVisibility(View.VISIBLE);
	}

	public void setLastOnClick(OnClickListener onClick) {
		mLast.setOnClickListener(onClick);
	}

	public void setLastGo() {
		mLast.setVisibility(View.GONE);
	}

	public LinearLayout getWheelViewGroup() {
		return mWheelViewGroup;
	}

	public WheelView getWheelViewByIndex(int index) {
		return (WheelView) mWheelViewGroup.getChildAt(index);
	}

	public void setWheelView(int type) {
		LayoutParams[] arrparams = null;
		switch (type) {
		case ACCOUNT:
			setWheelView(MyWheelView.ACCOUNT, 1, null, DATATYPE_STRING);
			break;
		case ITEM:
			setWheelView(MyWheelView.ITEM, 2, null, DATATYPE_STRING);
			break;
		case CHINA:
			setWheelView(MyWheelView.CHINA, 2, null, DATATYPE_STRING);
			break;
		case CHINA_FOOT:
			setWheelView(MyWheelView.CHINA_FOOT, 2, null, DATATYPE_STRING);
			break;
		case CALENDAR:
			LayoutParams params1 = new LayoutParams(LayoutParams.FILL_PARENT,
					LayoutParams.WRAP_CONTENT, 7);
			arrparams = new LayoutParams[3];
			arrparams[0] = arrparams[1] = params1;
			arrparams[2] = new LayoutParams(LayoutParams.FILL_PARENT,
					LayoutParams.WRAP_CONTENT, 8);
			setWheelView(MyWheelView.CALENDAR, 3, arrparams, DATATYPE_INT);
			break;
		case CALENDAR_ALL:
			LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT,
					LayoutParams.WRAP_CONTENT, 7);
			arrparams = new LayoutParams[5];
			arrparams[0] = params;
			arrparams[4] = arrparams[3] = arrparams[2] = arrparams[1] = new LayoutParams(
					LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 8);
			setWheelView(MyWheelView.CALENDAR, 5, arrparams, DATATYPE_INT);
		}
	}

	/**
	 * 添加wheelview
	 * 
	 * @param type
	 *            显示类型
	 * @param count
	 *            wheelview个数
	 * @param params
	 *            wheelview 布局
	 */
	public void setWheelView(int type, int count, LayoutParams[] params,
			int dataType, Object[]... data) {
		mType = type;

		if (mType == CALENDAR) {
			long currentTime = System.currentTimeMillis();
			calendar = Calendar.getInstance();
			calendar.setTimeInMillis(currentTime);
		}
		for (int i = 0; i < count; i++) {
			WheelView wheelView = new WheelView(context);
			wheelView.setId(mWheelViewGroup.getId() + i + 1);
			if (params == null) {
				wheelView.setLayoutParams(mParams);
			} else {
				wheelView.setLayoutParams(params[i]);
			}
			// 设置显示数
			wheelView.setVisibleItems(7);

			if (mType != OTHER) {
				if (i != count - 1) {
					wheelView.addChangingListener(this);
				}
				initWheelView(i, wheelView);
			} else {
				if (dataType == DATATYPE_INT) {
					if (data.length > i) {
						Object[] object = data[i];
						wheelView.setAdapter(new NumericWheelAdapter(
								(Integer) object[0], (Integer) object[1]));
					}
				} else if (dataType == DATATYPE_STRING) {
					if (data.length > i) {
						wheelView.setAdapter(new ArrayWheelAdapter<String>(
								(String[]) data[i]));
					}
				}
			}
			mWheelViewGroup.addView(wheelView); // wheelview添加到group
		}
		if (mType != OTHER) {
			initMoveWheelView();
		}

	}

	private void initWheelView(int i, WheelView wheelView) {
		if (mType == CHINA) { // 初始化数据

			switch (i) {
			case 0:
				wheelView
						.setAdapter(new ArrayWheelAdapter<String>(China.states));
				break;
			case 1:
				wheelView.setAdapter(new ArrayWheelAdapter<String>(
						China.counties[0]));
				break;
			case 2:
				String[] towns = { "" };
				wheelView.setAdapter(new ArrayWheelAdapter<String>(towns));
				break;
			}
		} else if (mType == CHINA_FOOT) { // 初始化数据

			switch (i) {
			case 0:
				wheelView
						.setAdapter(new ArrayWheelAdapter<String>(China.states));
				break;
			case 1:
				wheelView.setAdapter(new ArrayWheelAdapter<String>(
						China.counties_foot[0]));
				break;
			case 2:
				String[] towns = { "" };
				wheelView.setAdapter(new ArrayWheelAdapter<String>(towns));
				break;
			}
		} else if (mType == CALENDAR) {
			switch (i) {
			case 0:
				if(calendar_after_now){
					wheelView.setAdapter(new NumericWheelAdapter(1900, 2050));
				}else{
				wheelView.setAdapter(new NumericWheelAdapter(1900, calendar
						.get(Calendar.YEAR)));
				}
				break;
			case 1:
				if(calendar_after_now){
					wheelView.setAdapter(new NumericWheelAdapter(1, 12, "%02d"));
				}else{
				wheelView.setAdapter(new NumericWheelAdapter(1, calendar
						.get(Calendar.MONTH) + 1, "%02d"));
				}
				break;
			case 2:
				if(calendar_after_now){
					wheelView.setAdapter(new NumericWheelAdapter(1,DateUtil.getDays(calendar
							.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1), "%02d"));
				}else{
					if(isEndYesterDay){
						calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为当前日期的前一天
					}
				wheelView.setAdapter(new NumericWheelAdapter(1, calendar
						.get(Calendar.DATE), "%02d"));
				}
				if (calendar != null) {
					int day = calendar.get(Calendar.DAY_OF_MONTH);
					wheelView.setCurrentItem(day - 1);
					wheelView.setLabel("日");
					wheelView.setCyclic(false);//原来true
				}
				break;
			case 3:
				wheelView.setAdapter(new NumericWheelAdapter(0, 23, "%02d"));
				if (calendar != null) {
					int day = calendar.get(Calendar.HOUR_OF_DAY);
					wheelView.setCurrentItem(day);
					wheelView.setLabel("时");
					wheelView.setCyclic(true);
				}
				break;
			case 4:
				wheelView.setAdapter(new NumericWheelAdapter(0, 59, "%02d"));
				if (calendar != null) {
					int day = calendar.get(Calendar.MINUTE);
					wheelView.setCurrentItem(day);
					wheelView.setLabel("分");
					wheelView.setCyclic(true);
				}
				break;
			}
		} else if (mType == ITEM) {
			switch (i) {
			case 0:
				wheelView.setAdapter(new ArrayWheelAdapter<String>(
						KeepItem.sort));
				break;
			case 1:
				wheelView.setAdapter(new ArrayWheelAdapter<String>(
						KeepItem.item[0]));
				break;
			case 2:
				String[] towns = { "" };
				wheelView.setAdapter(new ArrayWheelAdapter<String>(towns));
				break;
			}
		}else if(mType == ACCOUNT){
			wheelView.setAdapter(new ArrayWheelAdapter<String>(
					KeepItem.sort));
		}
	}

	private void initMoveWheelView() {
		if (mType == CHINA) { // 格式化數據
			WheelView state = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 1);
			int countItem = state.getAdapter().getItemsCount();
			if (countItem >= 3 && countItem < 5) {
				state.setCurrentItem(1);
			} else if (countItem >= 5) {
				state.setCurrentItem(0);
			}
		} else if (mType == CHINA_FOOT) { // 格式化數據
			WheelView state = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 1);
			int countItem = state.getAdapter().getItemsCount();
			if (countItem >= 3 && countItem < 5) {
				state.setCurrentItem(1);
			} else if (countItem >= 5) {
				state.setCurrentItem(0);
			}
		} else if (mType == CALENDAR) {
			if (calendar != null) {
				WheelView yearView = (WheelView) mWheelViewGroup
						.findViewById(mWheelViewGroup.getId() + 1);
				int year = calendar.get(Calendar.YEAR);
				yearView.setCurrentItem(year - 1900);
				yearView.setLabel("年");

				WheelView monthView = (WheelView) mWheelViewGroup
						.findViewById(mWheelViewGroup.getId() + 2);
				int month = calendar.get(Calendar.MONTH);
				monthView.setCurrentItem(month);
				monthView.setLabel("月");
				monthView.setCyclic(false);
			}
		} else if (mType == ITEM) {
			WheelView state = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 1);
			int countItem = state.getAdapter().getItemsCount();
			if (countItem >= 3 && countItem < 5) {
				state.setCurrentItem(1);
			} else if (countItem >= 5) {
				state.setCurrentItem(0);
			}
		}
	}

	public void setMyVisible() {
		if (isInVisible) {
			if (getMyVisibility() == View.INVISIBLE
					|| getMyVisibility() == View.GONE) {
				mMainView.setVisibility(View.VISIBLE);
				return;
			}
		}

		if (isSlide) {
			if (getMyVisibility() != View.VISIBLE) {
				mMainView.startAnimation(mPush_in);
				mMainView.setVisibility(View.VISIBLE);
			}

			if (view != null && click != null) {
				view.setBackgroundDrawable(click);
			}

			if (editText != null) {
				editText.setFocusable(false);
			}
		} else {
			mMainView.setVisibility(View.VISIBLE);
		}
	}

	public void setMyGone() {
		if (isGone) {
			if (isInVisible) {
				mMainView.setVisibility(View.INVISIBLE);
				return;
			}
			if (isSlide) {
				if (getMyVisibility() == View.VISIBLE) {
					mMainView.startAnimation(mPush_out);
					mPush_out
							.setAnimationListener(new Animation.AnimationListener() {

								@Override
								public void onAnimationStart(Animation animation) {
									// TODO Auto-generated method stub

								}

								@Override
								public void onAnimationRepeat(
										Animation animation) {
									// TODO Auto-generated method stub

								}

								@Override
								public void onAnimationEnd(Animation animation) {
									// TODO Auto-generated method stub
									mMainView.setVisibility(View.GONE);
								}
							});
				}
			} else {
				mMainView.setVisibility(View.GONE);
			}

			if (view != null && noclick != null) {
				view.setBackgroundDrawable(noclick);
			}

			if (editText != null) {
				editText.setFocusable(true);
				editText.setFocusableInTouchMode(true);
			}
		}
	}

	public int getMyVisibility() {
		return mMainView.getVisibility();
	}

	@Override
	public void onChanged(WheelView wheel, int oldValue, int newValue) {
		// TODO Auto-generated method stub
		if (formatWheelView(wheel, oldValue, newValue)) {
			return;
		}

	}

	private boolean formatWheelView(WheelView wheel, int oldValue, int newValue) {
		boolean result = false;
		if (mType == CHINA) {
			formatChina(wheel, oldValue, newValue);
			result = true;
		} else if (mType == CALENDAR) {
			formatCalendar(wheel, oldValue, newValue);
			result = true;
		} else if (mType == ITEM) {
			formatItem(wheel, oldValue, newValue);
			result = true;
		}
		if (mType == CHINA_FOOT) {
			formatChinaFoot(wheel, oldValue, newValue);
			result = true;
		}
		return result;
	}

	private void formatChinaFoot(WheelView wheel, int oldValue, int newValue) {
		WheelView lastView = null;
		if (wheel.getId() - mWheelViewGroup.getId() == 1) {
			// recordNum1 = newValue;
			WheelView mCounties = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 2);
			mCounties.setAdapter(new ArrayWheelAdapter<String>(
					China.counties_foot[newValue]));
			if (China.counties_foot[newValue].length < 4) {
				mCounties.setCurrentItem(0);
			} else {
				mCounties.setCurrentItem(3);
			}
			lastView = mCounties;

		} else if (wheel.getId() - mWheelViewGroup.getId() == 2) {
			WheelView mTowns = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 3);
			lastView = mTowns;
			String[] towns = { "" };
			mTowns.setAdapter(new ArrayWheelAdapter<String>(towns));
			mTowns.setCurrentItem(1);
			mTowns.setCurrentItem(0);
		}
		if (lastView != null) {
			int countItem = lastView.getAdapter().getItemsCount();
			if (countItem >= 3 && countItem < 5) {
				lastView.setCurrentItem(1);
			} else if (countItem >= 5) {
				lastView.setCurrentItem(2);
			}
		}

	}

	private void formatItem(WheelView wheel, int oldValue, int newValue) {
		WheelView lastView = null;
		if (wheel.getId() - mWheelViewGroup.getId() == 1) {
			// recordNum1 = newValue;
			WheelView mCounties = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 2);
			mCounties.setAdapter(new ArrayWheelAdapter<String>(
					KeepItem.item[newValue]));
			lastView = mCounties;

		} else if (wheel.getId() - mWheelViewGroup.getId() == 2) {
			WheelView mTowns = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 3);
			lastView = mTowns;
			String[] towns = { "" };
			mTowns.setAdapter(new ArrayWheelAdapter<String>(towns));
			mTowns.setCurrentItem(1);
			mTowns.setCurrentItem(0);
		}
		if (lastView != null) {
			int countItem = lastView.getAdapter().getItemsCount();
			if (countItem >= 3 && countItem < 5) {
				lastView.setCurrentItem(1);
			} else if (countItem >= 5) {
				lastView.setCurrentItem(2);
			}
		}
	}

	private void formatChina(WheelView wheel, int oldValue, int newValue) {
		WheelView lastView = null;
		if (wheel.getId() - mWheelViewGroup.getId() == 1) {
			// recordNum1 = newValue;
			WheelView mCounties = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 2);
			mCounties.setAdapter(new ArrayWheelAdapter<String>(
					China.counties[newValue]));
			lastView = mCounties;

		} else if (wheel.getId() - mWheelViewGroup.getId() == 2) {
			WheelView mTowns = (WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 3);
			lastView = mTowns;
			String[] towns = { "" };
			mTowns.setAdapter(new ArrayWheelAdapter<String>(towns));
			mTowns.setCurrentItem(1);
			mTowns.setCurrentItem(0);
		}
		if (lastView != null) {
			int countItem = lastView.getAdapter().getItemsCount();
			if (countItem >= 3 && countItem < 5) {
				lastView.setCurrentItem(1);
			} else if (countItem >= 5) {
				lastView.setCurrentItem(2);
			}
		}
	}

	private void formatCalendar(WheelView wheel, int oldValue, int newValue) {
		if (calendar != null) {
			int day_in_month = 0;
			if (wheel.getId() - mWheelViewGroup.getId() == 2) {// 月份改变
				day_in_month = getDayInMonth(wheel);
				updateDay(day_in_month);
			} else if (wheel.getId() - mWheelViewGroup.getId() == 1) {// 年份改份改变

				day_in_month = getDayInMonth((WheelView) mWheelViewGroup
						.findViewById(mWheelViewGroup.getId() + 2));
				updateDay(day_in_month);

				int year = ((WheelView) mWheelViewGroup
						.findViewById(mWheelViewGroup.getId() + 1))
						.getCurrentItem() + 1900;
				int cur = calendar.get(Calendar.YEAR);
				if ((!calendar_after_now)&&cur == year) {
					updateMonth(calendar.get(Calendar.MONTH) + 1);
				} else {
					updateMonth(12);
				}
			}
		}
	}

	private int getDayInMonth(WheelView wheel) {
		int day_in_month = 0;
		int month = wheel.getCurrentItem() + 1;
		int maxday = calendar.get(Calendar.DAY_OF_MONTH);
		int curmoth = calendar.get(Calendar.MONTH)+1;

		int selyear = ((WheelView) mWheelViewGroup.findViewById(mWheelViewGroup
				.getId() + 1)).getCurrentItem() + 1900;
		int cur = calendar.get(Calendar.YEAR);
		// 在当前月，只能显示到今天
		if ((!calendar_after_now)&&month == curmoth && selyear == cur) {
			day_in_month = maxday;
		} else if (month == 1 || month == 3 || month == 5 || month == 7
				|| month == 8 || month == 10 || month == 12) {
			day_in_month = 31;
		} else if (month == 4 || month == 6 || month == 9 || month == 11) {
			day_in_month = 30;
		} else if (month == 2) {
			int year = ((WheelView) mWheelViewGroup
					.findViewById(mWheelViewGroup.getId() + 1))
					.getCurrentItem() + 1900;
			day_in_month = getFebruaryOfDay(year);
		}
		return day_in_month;
	}

	private int getFebruaryOfDay(int year) {
		if (year % 400 == 0) {
			return 29;
		} else if (year % 100 == 0) {
			return 28;
		} else if (year % 4 == 0) {
			return 29;
		} else {
			return 28;
		}
	}

	private void updateDay(int day_in_month) {
		WheelView day = (WheelView) mWheelViewGroup
				.findViewById(mWheelViewGroup.getId() + 3);
		int currentItem = day.getCurrentItem();

		day.setAdapter(new NumericWheelAdapter(1, day_in_month, "%02d"));
		if (currentItem == 0) {
			day.setCurrentItem(calendar.get(Calendar.DAY_OF_MONTH) - 1);
		} else if (day.getCurrentItem() > 0) {
			if (currentItem >= day.getAdapter().getItemsCount()) {
				day.setCurrentItem(day.getAdapter().getItemsCount() - 1, true);
			} else {
				day.setCurrentItem(currentItem);
			}
		}
	}

	private void updateMonth(int maxmonth) {
		WheelView month = (WheelView) mWheelViewGroup
				.findViewById(mWheelViewGroup.getId() + 2);
		int currentItem = month.getCurrentItem();

		month.setAdapter(new NumericWheelAdapter(1, maxmonth, "%02d"));
		if (currentItem == 0) {
			month.setCurrentItem(calendar.get(Calendar.MONTH) - 1);
		} else if (month.getCurrentItem() > 0) {
			if (currentItem >= month.getAdapter().getItemsCount()) {
				month.setCurrentItem(month.getAdapter().getItemsCount() - 1,
						true);
			} else {
				month.setCurrentItem(currentItem);
			}
		}
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.my_wheelview_ok:
			flashData();
			if (mMainView != null && mMainView.getVisibility() == View.VISIBLE) {
				setMyGone();
			}
			break;
		case R.id.my_wheelview_cancel:
			if (mMainView != null && mMainView.getVisibility() == View.VISIBLE) {
				setMyGone();
			}

			break;
		case R.id.my_wheelview_last:
			if (mMainView != null && mMainView.getVisibility() == View.VISIBLE) {
				setMyGone();
			}

			flashData();
			break;
		}
	}

	WheelView wheelView;
	public void flashData() {
		String result = "";
		String dataNumber = "";
		if (listener != null) {
			for (int i = 0; i < mWheelViewGroup.getChildCount(); i++) {
				wheelView = (WheelView) mWheelViewGroup.getChildAt(i);
				WheelAdapter adapter = wheelView.getAdapter();
				String data = adapter.getItem(wheelView.getCurrentItem());
				if (i != 0) {
					result += ",";
					dataNumber += ",";
				}
				if (data == null) {
					data = "";
				}
				result += data;
				dataNumber += wheelView.getCurrentItem();
			}
		}
		if (mType == CHINA || mType == CHINA_FOOT) {
			if (!"".equals(result)) {
				result = result + "&#&" + dataNumber;
			}
		}
		
		if(mType == ACCOUNT){
			result = result + "#" + wheelView.getCurrentItem();
		}
		
		if (listener != null) {
			listener.updataByChanger(result);
		}

	}

	public void setOnWheelViewDataChanger(OnWheelViewDataChanger listener) {
		this.listener = listener;
	}

	/**
	 * 点确定时调用
	 * 
	 * @author lmf
	 * 
	 */
	public interface OnWheelViewDataChanger {
		public void updataByChanger(String data);
	}

	public boolean getIsDone() {
		boolean isDone = false;
		if ("确定".equals(mOk.getText().toString())) {
			isDone = true;
		}
		return isDone;
	}

	public boolean getGone() {
		// TODO Auto-generated method stub
		return isGone;
	}
}
